<?php
return array(
	'rules' => array(
		array('pay_type', 'required'),
		array('providerId', 'safe'),
	),
	'relations' => array(
		'items' => array(
			CActiveRecord::HAS_ONE, 'OrderItem', 'order_id',
		),
		'receiverInfo' => array(CActiveRecord::HAS_ONE, 'OrderReceiverInfo', 'order_id'),
		'member' => array(CActiveRecord::BELONGS_TO, 'MemberAccount','worker_id'),
		'pay' => array(CActiveRecord::HAS_ONE, 'PaymentBill', 'payment_id'),
	),
	'attributeLabels' => array(
		'sn' => '订单编号',
		'object_type' => '订单类型',
		'status' => '状态',
		'profile' => '订单详情',
		'receiverInfo' => '预定人信息',
		'items' => '订单项',
		'remark' => '备注',
		'create_time' => '下单时间',
		'update_time' => '修改时间',
		'travelers' => '旅客信息',
		'totalPrice' => '订单金额',
		'selectTime' => '下单时间',
		'providerId' => '供应商',
		'total' => '订单总价'
	),
	'behaviors' => array(
		'search' => array(
			'class' => 'application.behaviors.SearchBehavior',
			'timeSearch' => 'create_time',
			'searchModel' => 'OrderSearch'
		),
		'stateHandle' => array(
			'class' => 'ModelState',
			'handleField' => 'status',
			'configName' => 'status.order.audit',
			'configReader' => Yii::app()->config,
			'initState' => 'ST_NONE',
		),
		'userScope' => array(
			'class' => 'coms.behaviors.userScopes.DefaultScope',
			'relatedFields' => array(
				'items.provider_id',
				'items.dealer_id',
			),
		),
		'perfectOrder' => array(
			'class' => 'application.behaviors.PerfectOrderBehavior',
		),
//		'createTime' => array(
//			'class' => 'application.behaviors.CreateTimeBehavior',
//		),
		'receiver' => array(
			'class' => 'application.behaviors.AccountingBehavior',
			'status' => 'ST_FINISHED',
		),
		'autoTime' => array(
			'class' => 'lib.behaviors.auto.CCreateTime',
			'attribute' => 'create_time'
		),
		'aoutUpdate'=>array(
			'class'=>'lib.behaviors.auto.CUpdateTime',
		),
		'uidResolver' => array(
			'class' => 'application.behaviors.LyAutoIdBehavior',
			'uid' => 'worker_id'
		),
		'autoSn' => array(
			'class' => 'application.behaviors.AutoSnBehavior',
			'attribute' => 'sn'
		),
		'offlinePay' => array(
			'class' => 'coms.behaviors.order.PayOfOffline'
		),
		'totalPrice' => 'coms.behaviors.order.TotalPriceBehavior'
	),
	'cascade' => array(
		'items', 'receiverInfo',
	),
	
	'_import' => array(
		array('*', 'models.ActiveRecord//*'),
	),
);